package com.cwh.taskcenter.domain.notice.model;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 通知触发类型枚举
 * @author cwh
 */
@Getter
@AllArgsConstructor
public enum TriggerType {
    TASK_COMPLETION("TASK_COMPLETION", "任务完成时"),
    TASK_EXPIRING("TASK_EXPIRING", "任务即将过期时"),
    REWARD_GRANT("REWARD_GRANT", "奖励发放时");

    private final String code;
    private final String description;

    public static TriggerType fromCode(String triggerType) {
        for (TriggerType type : TriggerType.values()) {
            if (Objects.equals(type.code, triggerType)) {
                return type;
            }
        }
        return null;
    }
}
